package meihua.stopcarapp.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;
import meihua.mylibrary.base.BaseActivity;
import meihua.stopcarapp.R;
import meihua.stopcarapp.app.UserConfig;
import meihua.stopcarapp.bean.CouponEntity;
import meihua.stopcarapp.model.StopCarQuanModel;
import meihua.stopcarapp.presenter.StopCarQuanPresenter;
import meihua.stopcarapp.presenter.contract.StopCarQuanContract;
import meihua.stopcarapp.ui.adapter.StopCarQuanAdapter;

/**
 * 停车券
 */
public class StopCarQuanActivity extends BaseActivity<StopCarQuanPresenter,StopCarQuanModel> implements StopCarQuanContract.View {
    @Bind(R.id.toolbar_left)
    ImageView toolbarLeft;
    @Bind(R.id.toolbar_center)
    TextView toolbarCenter;
    @Bind(R.id.stop_car_quan_list)
    ListView stopCarQuanList;
    private StopCarQuanAdapter adapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_stop_car_quan;
    }

    @Override
    public void initPresenter() {
        mPresenter.setVM(this,mModel);
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        toolbarCenter.setText( "我的车位券" );
        mPresenter.getCouponListRequest(UserConfig.USER_ENTITY.getUser_id());
    }

    @OnClick({R.id.toolbar_left})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.toolbar_left:
                finish();
                break;
            case R.id.stop_car_quan_list:
                break;
        }
    }

    public static void startAction(Activity activity) {
        Intent intent = new Intent( activity, StopCarQuanActivity.class );
        activity.startActivity( intent );
        activity.overridePendingTransition( R.anim.fade_in, R.anim.fade_out );
    }

    @Override
    public void showLoading(String title) {

    }

    @Override
    public void stopLoading() {

    }

    @Override
    public void showErrorTip(String msg) {

    }

    @Override
    public void returnCouponList(List<CouponEntity> earnings) {
        adapter = new StopCarQuanAdapter(this,earnings);
        stopCarQuanList.setAdapter(adapter);//测试adapter效果 没传数据源
    }
}
